{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Python Operators.ipynb",
      "provenance": [],
      "authorship_tag": "ABX9TyNvJZBpgaIB1FvTjfSEWKAI",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/Tanu-N-Prabhu/Python/blob/master/Python_Operators.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "rikeOIyqTt7k",
        "colab_type": "text"
      },
      "source": [
        "# **Python Operators from Scratch!!! - A Beginner's Guide**\n",
        "\n",
        "## In this tutorial, you will learn one of the basic and important concepts in python known as operators, their syntax along with examples.\n",
        "\n",
        "![alt text](https://cdn-images-1.medium.com/max/1200/1*jsf_wiMOoAq-L-_JQG1_Nw.jpeg)\n",
        "\n",
        "\n",
        "# **What is an Operator?**\n",
        "\n",
        "An operator is a **character** or **set of characters** that can be used to perform the **desired operation** on the **operands** and produce the **final result**.\n",
        "\n",
        "\n",
        "\n",
        "> The final result completely depends on the type of operators used.\n",
        "\n",
        "For example, consider you want to perform a mathematical calculation of **5+3**. Now both **5** and **3** are called **operands**, **+** is the **operator** that performs **addition** and the final result is **8**.\n",
        "\n",
        "---\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "waibQz6UWApe",
        "colab_type": "text"
      },
      "source": [
        "# **Types of Operators**\n",
        "\n",
        "\n",
        "![alt text](https://cdn-images-1.medium.com/max/1200/1*X1uStrlHrq2T6tWvuKSxeA.png)\n",
        "\n",
        "\n",
        "**The different types of operators supported by Python are as follows:**\n",
        "\n",
        "1. Arithmetic Operators\n",
        "2. Relational Operators\n",
        "3. Logical Operators\n",
        "4. Bitwise Operators\n",
        "5. Assignment Operators\n",
        "6. Identity Operators\n",
        "7. Membership Operators\n",
        "\n",
        "\n",
        "---"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "UbEC86y_WSzu",
        "colab_type": "text"
      },
      "source": [
        "# **Arithmetic Operators**\n",
        "\n",
        "Arithmetic operators are used in performing mathematical operations such as **Addition, Subtraction, Multiplication, Division, Modulus, Floor Division, and Exponent**.\n",
        "\n",
        "\n",
        "![alt text](https://cdn-images-1.medium.com/max/1200/1*CnFBU56b1HIsg2atttE_-Q.png)\n",
        "\n",
        "\n",
        "## **Example**\n",
        "\n",
        "Below is the simple python snippet that you can use as a reference:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "e3JZKQaEWjaY",
        "colab_type": "code",
        "outputId": "bb1792ec-32b9-4654-9acf-03bf10717252",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 139
        }
      },
      "source": [
        "# Assigning values to variables\n",
        "a = 10\n",
        "b = 5\n",
        "# Addition\n",
        "print('a + b =', a + b)\n",
        "# Subtraction\n",
        "print('a - b =', a - b)\n",
        "# Multiplication\n",
        "print('a * b =', a * b)\n",
        "# Division\n",
        "print('a / b =', a / b)\n",
        "# Modulus\n",
        "print('a % b =', a % b)\n",
        "# Floor Division\n",
        "print('a // b =', a // b)\n",
        "# Exponent\n",
        "print('a ** b =', a ** b)"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "a + b = 15\n",
            "a - b = 5\n",
            "a * b = 50\n",
            "a / b = 2.0\n",
            "a % b = 0\n",
            "a // b = 2\n",
            "a ** b = 100000\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "d2-utxqyWnjT",
        "colab_type": "text"
      },
      "source": [
        "## **Important Notes**\n",
        "\n",
        "1. If you divide any number by **0** then you will be prompted by an error called `ZeroDivisionError`.  Don't divide anything by zero (0).\n",
        "\n",
        "2. The result generated by the division operator will always be **floating number** (represented in decimal points).\n",
        "\n",
        "3. **Floor division** returns the quotient(answer or result of **division**) in which the digits after the decimal point are removed. But if one of the operands(dividend and divisor) is negative, then the result is floored, i.e., rounded away from zero(means, towards the negative of infinity).\n",
        "\n",
        "![alt text](https://cdn-images-1.medium.com/max/1200/1*p_BpdHXkMyHgwkXV4tSuig.png)\n",
        "\n",
        "---"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "3GDFYhPDXBn5",
        "colab_type": "text"
      },
      "source": [
        "Relational Operators\n",
        "Relational operators or comparison operators as their name suggest are used in comparing the values. The return type of these operators are either True or False. The different comparison operators are Greater than, Greater than or equal to, less than, lesser than or equal to, equal to, and not equal to.\n",
        "\n",
        "\n",
        "![alt text](https://miro.medium.com/max/1400/1*1PElDsGJozY_dAPcmf8Kqg.png)\n",
        "\n",
        "## **Example**\n",
        "\n",
        "Below is the simple python snippet that you can use as a reference:\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "R08V15fHgf0a",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 121
        },
        "outputId": "12e48afc-a9d8-4ce5-820e-099dce922905"
      },
      "source": [
        "# Assigning values to variables\n",
        "a = 10\n",
        "b = 5\n",
        "# Greater than\n",
        "print('a > b =', a > b)\n",
        "# Lesser than\n",
        "print('a < b =', a < b)\n",
        "# Equal to\n",
        "print('a == b =', a == b)\n",
        "# Not equal to\n",
        "print('a != b =', a != b)\n",
        "# Greater than or equal to\n",
        "print('a >= b =', a >= b)\n",
        "# Lesser than or equal to\n",
        "print('a <= b =', a <= b)"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "a > b = True\n",
            "a < b = False\n",
            "a == b = False\n",
            "a != b = True\n",
            "a >= b = True\n",
            "a <= b = False\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "9WjZOg3ggnAm",
        "colab_type": "text"
      },
      "source": [
        "## **Important notes**\n",
        "\n",
        "1. Relational operators are also called **comparison operators**.\n",
        "\n",
        "2. The comparison operator can be used to compare more than two values. For example `5 > 3 < 1` will result in `False`.\n",
        "\n",
        "3. These are also called as **relational operators** because it compares the value and then decides the relation among them. For example, `5 > 4` the relation is such that **5 is greater than 4** and the answer is `True`. The relation here is **greater**.\n",
        "\n",
        "---\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "EGag_O-rhRjh",
        "colab_type": "text"
      },
      "source": [
        "# **Logical Operators**\n",
        "\n",
        "\n",
        "Logical operators are used to **evaluate the conditions** between the operands. The different type of operators are `and`, `or` and `not`.\n",
        "\n",
        "\n",
        "![alt text](https://miro.medium.com/max/1400/1*pV1plvnbr00q_B5_V-wMdg.png)\n",
        "\n",
        "\n",
        "To make things more clear you can refer to the truth table of the logical operators given below:\n",
        "\n",
        "![alt text](https://miro.medium.com/max/1028/1*bnTf9sHiXAZ086dXoL8d_g.jpeg)\n",
        "\n",
        "\n",
        "## **Example**\n",
        "Below is the simple python snippet that you can use as a reference:\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "D5WhngmEiRgL",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 69
        },
        "outputId": "0a8c7db2-b6d1-4cda-aba4-28367e246f2e"
      },
      "source": [
        "# Assigning values to variable\n",
        "a = True\n",
        "b = False\n",
        "# Logical and\n",
        "print('a and b is',a and b)\n",
        "# Logical or\n",
        "print('a or b is',a or b)\n",
        "# Logical not\n",
        "print('not a is',not a)"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "a and b is False\n",
            "a or b is True\n",
            "not a is False\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7-AbVGRZiY7D",
        "colab_type": "text"
      },
      "source": [
        "## **Important notes**\n",
        "\n",
        "1. Logical operators are also called as **Boolean Operators**.\n",
        "\n",
        "2. If the operands are not boolean then it would be automatically converted to a boolean for the evaluation.\n",
        "\n",
        "\n",
        "3. The logical operators can be applied to any type of value. For example, they can be applied to **strings** as shown below. In this case, the **and** operator returns the first false value if there are null **or** false values otherwise, they return the last value. The or returns the first true value if there are any otherwise returns the last value."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "79PaBJTxjGy2",
        "colab_type": "text"
      },
      "source": [
        "## **Logical “and” operator on Strings**\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "iGncVsfcjKai",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "c91116e2-50b9-4506-9705-6da1eed1134a"
      },
      "source": [
        "a = \"\"\n",
        "b = \"Python\"\n",
        "a and b"
      ],
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "''"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 3
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "e8EuwgPhjMIj",
        "colab_type": "text"
      },
      "source": [
        "## **Logical “or” operator on Strings**\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0wpuLNObjPKD",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "24627649-007a-4315-8ba1-9e7ce131616b"
      },
      "source": [
        "a = \"\"\n",
        "b = \"Python\"\n",
        "a or b"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'Python'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 4
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "fQIMZI6vjRgt",
        "colab_type": "text"
      },
      "source": [
        "4. In both the cases of `and`, `or` the evaluation is done from **left** to **right**.\n",
        "\n",
        "---"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "DKBFdls7jZtC",
        "colab_type": "text"
      },
      "source": [
        "# **Bitwise Operators**\n",
        "\n",
        "Bitwise operators operate on operands at a binary level. Meaning the bitwise operator looks directly at the binary digits or binary bits of an integer. Hence the name bitwise (bit by bit operation). The different types of bitwise operators are **Bitwise AND, OR, NOT, XOR, Right Shift, and Left Shift**.\n",
        "\n",
        "![alt text](https://miro.medium.com/max/1400/1*4O0nEUQpc6r1Fmm3pNVpnA.png)\n",
        "\n",
        "## **Example**\n",
        "\n",
        "Below is the simple python snippet that you can use as a reference:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ELWROe-TkA3E",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 121
        },
        "outputId": "4a3a3bda-4bb3-4e0c-f823-eb8d8178633d"
      },
      "source": [
        "# Assigning values to variables\n",
        "a = 10\n",
        "b = 11\n",
        "# Bitwise AND\n",
        "print('a & b is',a & b)\n",
        "# Bitwise OR\n",
        "print('a | b is',a | b)\n",
        "# Bitwise XOR\n",
        "print('a ^ b is',a ^ b)\n",
        "# Bitwise NOT\n",
        "print('~a is',~a)\n",
        "# Bitwise Left Shift\n",
        "print('a << b is',a << b)\n",
        "# Bitwise Right Shift\n",
        "print('a >> b is',a >> b)"
      ],
      "execution_count": 5,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "a & b is 10\n",
            "a | b is 11\n",
            "a ^ b is 1\n",
            "~a is -11\n",
            "a << b is 20480\n",
            "a >> b is 0\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "BuNAX0alkDx0",
        "colab_type": "text"
      },
      "source": [
        "## **Important Notes**\n",
        "\n",
        "1. Bitwise operator works on **bits** and performs a **bit by bit** operation on the operands.\n",
        "\n",
        "2. No matter the type of operands you pass, the bitwise operator will convert it to a series of binary digits respectively. For example, if an operand is **2** then its binary format is **10**, similarly, **9** will be rendered as **1001** and so on. Below is the **truth table of bitwise operators** excluding left and right shift operators.\n",
        "\n",
        "\n",
        "![alt text](https://miro.medium.com/max/1388/1*bv5c8RMsrK0opPUv_jaf4Q.png)\n",
        "\n",
        "---"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "tSRV6nmmkuD-",
        "colab_type": "text"
      },
      "source": [
        "# **Assignment Operators**\n",
        "\n",
        "As the name suggests assignments operators are used to **assigning the values to the variables**. Let me give you a simple example.\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QWTm2KDwk2Le",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "a = 5"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "oeQk1g5sk4N7",
        "colab_type": "text"
      },
      "source": [
        "Many at times people make mistakes while reading the above line of code. People say “**a equals to 5**”, this might sound correct, but programmatically it’s incorrect. The correct way is:"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "QE497hLtk7LO",
        "colab_type": "text"
      },
      "source": [
        "\n",
        "\n",
        "> ***The value 5 is assigned to the variable ‘a’***\n",
        "\n",
        "Because the way the assignment operator works is that it assigns the value from the right to the variable on to the left. So remember its **right to left**.\n",
        "\n",
        "![alt text](https://miro.medium.com/max/1400/1*50jAvLZKuCV_wtp9p5k4Qg.png)\n",
        "\n",
        "\n",
        "## **Example**\n",
        "\n",
        "Below is the simple python snippet that you can use as a reference:\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "H1cZTTgPlIwz",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 225
        },
        "outputId": "1f66c4f3-e432-4c48-849c-a50cb08d6246"
      },
      "source": [
        "# Assigning the values to variables\n",
        "a = 15\n",
        "b = 5\n",
        "# Simple assignment operator\n",
        "b = a\n",
        "print('b = a: ',b)\n",
        "# ADD AND operator\n",
        "b += a\n",
        "print('b += a: ', b)\n",
        "# SUBTRACT AND operatpr\n",
        "b -= a\n",
        "print('b -= a: ', b)\n",
        "# MULTIPLICATION AND operator\n",
        "b *= a\n",
        "print('b *= a: ', b)\n",
        "# DIVISION AND operator\n",
        "b /= a\n",
        "print('b /= a: ', b)\n",
        "# FLOOR AND operator\n",
        "b //= a\n",
        "print('b //= a: ', b)\n",
        "# MODULUS AND operator\n",
        "b %= a\n",
        "print('b %= a: ', b)\n",
        "# EXPONENT AND operator\n",
        "b **= a\n",
        "print('b **= a: ', b)\n",
        "# LESS THAN AND operator\n",
        "b <= a\n",
        "print('b <= a: ', b)\n",
        "# GREATOR THAN AND operator\n",
        "b >= a\n",
        "print('b >= a: ', b)\n",
        "# BINARY AND operator\n",
        "a &= 5\n",
        "print('a &= 5: ', a)\n",
        "# BINARY OR operator\n",
        "a |= 5\n",
        "print('a |= 5: ', a)"
      ],
      "execution_count": 7,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "b = a:  15\n",
            "b += a:  30\n",
            "b -= a:  15\n",
            "b *= a:  225\n",
            "b /= a:  15.0\n",
            "b //= a:  1.0\n",
            "b %= a:  1.0\n",
            "b **= a:  1.0\n",
            "b <= a:  1.0\n",
            "b >= a:  1.0\n",
            "a &= 5:  5\n",
            "a |= 5:  5\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "j_9HIawClN1Y",
        "colab_type": "text"
      },
      "source": [
        "## **Notes**\n",
        "\n",
        "1. We can extend the assignment operators for more operators such as `-, /, *, //, %, <<, >>, &, |, **, ^`. For example: `a **= 5`, will be `a = a**5`, the answer would be `298023223876953125`. Make sure that you write the **operator** followed by the **assignment operator**.\n",
        "\n",
        "---\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "mKe2LugclryP",
        "colab_type": "text"
      },
      "source": [
        "# **Special Operators**\n",
        "\n",
        "There are two types of special operators in a python programming language as shown below:\n",
        "\n",
        "## **Identity Operators**\n",
        "\n",
        "As the name suggests the identity operators compare the **id (identity)** of two or more python objects such as variables, values, and many more. In other words, others say that the identity operator can also be used to **compare the memory locations of two objects**. There are two types of identity operators namely `is` and `is not`.\n",
        "\n",
        "\n",
        "![alt text](https://miro.medium.com/max/1400/1*IqGzM2dHP97kve6T90omdQ.png)\n",
        "\n",
        "\n",
        "## **Example**\n",
        "\n",
        "Below is the simple python snippet that you can use as a reference:\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "HjEUOYftmAzN",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "outputId": "3358ea66-2c15-477d-dd51-1370e6d79d22"
      },
      "source": [
        "# Assigning values to variables\n",
        "a = 10\n",
        "b = 11\n",
        "# Identity is operator\n",
        "print('a is b is',a is b)\n",
        "# Identity is not operator\n",
        "print('a is not b is',a is not b)"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "a is b is False\n",
            "a is not b is True\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "TmdUnn8MmESi",
        "colab_type": "text"
      },
      "source": [
        "## **Important Notes**\n",
        "\n",
        "\n",
        "1. In general, the identity operator does not compare the value or object itself. Rather it compares the **id’s (identity)**. Below is an example:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "XKdjhfcnmLYk",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 87
        },
        "outputId": "9424c818-65e7-45b3-a9b8-56559575d389"
      },
      "source": [
        "# Assigning the values to variables\n",
        "a = 5\n",
        "b = 5\n",
        "c = a\n",
        "# Getting the id of the variables\n",
        "print(id(a))\n",
        "print(id(b))\n",
        "print(id(c))\n",
        "# Comparing the id of a and c\n",
        "print(a is c)"
      ],
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "10914624\n",
            "10914624\n",
            "10914624\n",
            "True\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "WcNEP-w5mPbK",
        "colab_type": "text"
      },
      "source": [
        "To compare the id’s you can use the id function in python. It returns the id of the memory location.\n",
        "\n",
        "---"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "dbIwcSGVmRI8",
        "colab_type": "text"
      },
      "source": [
        "## **Membership Operators**\n",
        "\n",
        "Membership operators are used to **verifying whether a particular element** is a **part of a sequence or not**. Now a sequence can be a **list, string, sets, dictionary, and tuples**. The two membership operators are `in` and `not in`.\n",
        "\n",
        "![alt text](https://miro.medium.com/max/1400/1*t2u2Lb4XtVo-3g6anMBLpw.png)\n",
        "\n",
        "\n",
        "## **Example**\n",
        "\n",
        "Below is the simple python snippet that you can use as a reference:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "-5aPhQrymvso",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 69
        },
        "outputId": "f39c2293-b986-4d3f-83d4-805fab19413e"
      },
      "source": [
        "# Assigning a string value to a variable\n",
        "a = \"Python\"\n",
        "# Type of the variable\n",
        "print(type(a))\n",
        "# Checking whether 'y' is present in the variable a or not\n",
        "print('y' in a)\n",
        "# Checking whether 'P' is present in the variable a or not\n",
        "print('p' not in a)"
      ],
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'str'>\n",
            "True\n",
            "True\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ti4JeXsRmxn8",
        "colab_type": "text"
      },
      "source": [
        "## **Important Notes**\n",
        "\n",
        "While we can use membership operators on dictionaries but there is one thing you should know i.e. we can only test for the presence of the **key and not the value** as shown below:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7g52exbum2NP",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "outputId": "902f7217-d50e-4154-d397-75f6fb07333f"
      },
      "source": [
        "# Dictionary with key as 1, 2 and values as 'A' and 'B'\n",
        "a = {1: \"A\", 2: 'B'}\n",
        "# Using 'in' operator\n",
        "print(2 in a)\n",
        "# Using 'not in' operator\n",
        "print(3 not in a)"
      ],
      "execution_count": 11,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "True\n",
            "True\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4W-XcvIznBoz",
        "colab_type": "text"
      },
      "source": [
        "\n",
        "\n",
        "---\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "IZtXMANNnCGb",
        "colab_type": "text"
      },
      "source": [
        "Well done, good job guys, you have reached the end of the tutorial “**Python Operators from Scratch!!! — A Beginner’s Guide**”. I hope after reading this tutorial you have strong knowledge about the python operators. If you have any doubts regarding the tutorial, let me know via the comment section down below. I try to answer it as soon as I can. All right until then see you next time, have a good one, stay safe.\n",
        "\n",
        "\n",
        "\n",
        "---\n",
        "\n"
      ]
    }
  ]
}